import { request } from "vendor/utils/T";
import { toApi } from "@/service/proxyApi";
import {RespDataType, RequestDataType} from "./apiType";

export * from "./apiType";
const {get, postJSON, del, put } = request;

/**
 * 获取菜单管理列表数据
 */
export const getMenuList = (params:{menuName?: string, component?: string})=>{
  return get<RespDataType.MenuListResp>(toApi("api/v1/system/menu/list"),params)
}

// /**
//  * 获取选择列表数据
//  */
// export const getMenuSelectList = ()=>{
//     return get<RespSysSettingDataType.TreeSelectData[]>(toApi("/system/menu/treeSelectData"))
// }

/**
 * 创建菜单
 */
export const createMenu = (params:RequestDataType.CreateMenuItem)=>{
    return postJSON(toApi("api/v1/system/menu/add"),params);
}

/**
 * 更新菜单
 */
export const updateMenu = (menuId:number, params:RequestDataType.CreateMenuItem) => {
    params = {...params, id:menuId};
    return put(toApi("api/v1/system/menu/update"), params);
}

/**
 * 删除菜单
 */
export const deleteMenu = (menuIdList: number[]) => {
    return del(toApi("api/v1/system/menu/delete"), {ids: menuIdList});
}

/**
 * 获取菜单
 */
export const getMenu = (menuId: number) => {
    return get<RespDataType.MenuInfoResp>(toApi("api/v1/system/menu/get"), {id: menuId});
}
